package vizualize;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.view.Gravity;
import android.view.View;
import android.util.AttributeSet;
import android.widget.Toast;

import maze.mazeMap;
import maze.Cell;
import hero.protagonist;

/**
 * Created by Роман on 07.05.14.
 */
public class mazePainter extends View
{
    int dispWidth, dispHeight;
    float koeffD, koeffO;
    int size;
    private Canvas mCanvas;
    private Bitmap mBitmap;
    private Paint paint, mBitmapPaint;
    private Context my;

    public mazePainter(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        my = this.getContext();
    }

    public void setParams(int width, int height, int val)
    {
        dispHeight = height;
        dispWidth = width;
        size = val;
        switch(size)
        {
            case 10:
            {
                koeffD = 1;
                koeffO = 0.5f;
                break;
            }
            case 15:
            {
                koeffD = 0.666f;
                koeffO = 0.75f;
                break;
            }
            case 20:
            {
                koeffD = 0.5f;
                koeffO = 0.9f;
                break;
            }
        }
        mBitmap = Bitmap.createBitmap(dispWidth, dispHeight, Bitmap.Config.ARGB_8888);
        mCanvas = new Canvas(mBitmap);
        mBitmapPaint = new Paint();
        paint = new Paint();
        paint.setColor(Color.rgb(230, 230, 255));
    }
    @Override
    protected void onDraw(Canvas canvas)
    {
        canvas.save();
        canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
        canvas.restore();
//        super.onDraw(canvas);
//        Paint paint = new Paint();
//
//        float partSize = (float)dispHeight / 11;
//
//        mazeMap maze = new mazeMap(size);
//        Cell[][] map;
//        map = maze.create();
//
//        paint.setStyle(Paint.Style.STROKE);
//        paint.setStrokeJoin(Paint.Join.ROUND);
//        paint.setStrokeCap(Paint.Cap.ROUND);
//
//        canvas.drawPaint(paint);
//
////        paint.setColor(Color.rgb(0, 64, 128));
//        paint.setColor(Color.rgb(0, 72, 145));
//        //canvas.drawRect(partSize, partSize, partSize*10, partSize*10, paint);
//        float coordX, coordY;
//        for(int i = 0; i < size; i++)
//        {
//            coordX = partSize*koeffO + partSize*i;
//            for(int j = 0; j < size; j++)
//            {
//                coordY = partSize*koeffO + partSize*j;
//
////                paint.setColor(Color.rgb(0, 120, 240));
//                paint.setColor(Color.rgb(187, 187, 255));
//                paint.setStrokeWidth(1);
//                canvas.drawLine(coordX*koeffD, coordY*koeffD, (coordX+ partSize)*koeffD, coordY*koeffD, paint);
//                canvas.drawLine(coordX*koeffD, (coordY + partSize)*koeffD, (coordX + partSize)*koeffD, (coordY + partSize)*koeffD, paint);
//                canvas.drawLine(coordX*koeffD, coordY*koeffD, coordX*koeffD, (coordY + partSize)*koeffD, paint);
//                canvas.drawLine((coordX + partSize)*koeffD, coordY*koeffD, (coordX + partSize)*koeffD, (coordY + partSize)*koeffD, paint);
//                paint.setStrokeWidth(4);
//                paint.setColor(Color.rgb(0, 72, 145));
//
//                if(map[i][j].getWall(1))
//                    canvas.drawLine(coordX*koeffD, coordY*koeffD, (coordX+ partSize)*koeffD, coordY*koeffD, paint);
//                if(map[i][j].getWall(2))
//                    canvas.drawLine(coordX*koeffD, (coordY + partSize)*koeffD, (coordX + partSize)*koeffD, (coordY + partSize)*koeffD, paint);
//                if(map[i][j].getWall(3))
//                    canvas.drawLine(coordX*koeffD, coordY*koeffD, coordX*koeffD, (coordY + partSize)*koeffD, paint);
//                if(map[i][j].getWall(4))
//                    canvas.drawLine((coordX + partSize)*koeffD, coordY*koeffD, (coordX + partSize)*koeffD, (coordY + partSize)*koeffD, paint);
//            }
//        }
//
//        paint.setStyle(Paint.Style.FILL);
//        paint.setTextSize(partSize*3/4);
//
//        paint.setColor(Color.rgb(179, 0, 0));
//        canvas.drawText("Health:", partSize*12, partSize*3-partSize*3/4, paint);
//        paint.setColor(Color.rgb(0, 0, 150));
//        canvas.drawText("Speed:", partSize*12, partSize*3, paint);
//        paint.setColor(Color.rgb(0, 100, 0));
//        canvas.drawText("Status:", partSize*12, partSize*3+partSize*3/4, paint);
//
//// восстанавливаем холст
//        canvas.restore();
    }

    public int getDispHeight()
    {
        return dispHeight;
    }
    public void init()
    {
        float partSize = (float)dispHeight / 11;

        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeJoin(Paint.Join.ROUND);
        paint.setStrokeCap(Paint.Cap.ROUND);

        mCanvas.drawPaint(paint);

        paint.setColor(Color.rgb(0, 72, 145));
        float coordX, coordY;
        for(int i = 0; i < size; i++)
        {
            coordX = partSize*koeffO + partSize*i;
            for(int j = 0; j < size; j++)
            {
                coordY = partSize*koeffO + partSize*j;

//                paint.setColor(Color.rgb(0, 120, 240));
                paint.setColor(Color.rgb(187, 187, 255));
                paint.setStrokeWidth(1);
                mCanvas.drawLine(coordX*koeffD, coordY*koeffD, (coordX+ partSize)*koeffD, coordY*koeffD, paint);
                mCanvas.drawLine(coordX*koeffD, (coordY + partSize)*koeffD, (coordX + partSize)*koeffD, (coordY + partSize)*koeffD, paint);
                mCanvas.drawLine(coordX*koeffD, coordY*koeffD, coordX*koeffD, (coordY + partSize)*koeffD, paint);
                mCanvas.drawLine((coordX + partSize)*koeffD, coordY*koeffD, (coordX + partSize)*koeffD, (coordY + partSize)*koeffD, paint);
                paint.setStrokeWidth(4);
                paint.setColor(Color.rgb(0, 72, 145));

                if(j==0)
                    mCanvas.drawLine(coordX*koeffD, coordY*koeffD, (coordX+ partSize)*koeffD, coordY*koeffD, paint);
                if(j==size-1)
                    mCanvas.drawLine(coordX*koeffD, (coordY + partSize)*koeffD, (coordX + partSize)*koeffD, (coordY + partSize)*koeffD, paint);
                if(i==0)
                    mCanvas.drawLine(coordX*koeffD, coordY*koeffD, coordX*koeffD, (coordY + partSize)*koeffD, paint);
                if(i==size-1)
                    mCanvas.drawLine((coordX + partSize)*koeffD, coordY*koeffD, (coordX + partSize)*koeffD, (coordY + partSize)*koeffD, paint);
            }
        }

        paint.setStyle(Paint.Style.FILL);

        this.printMessage("HEALTH: 100", 0);
        this.printMessage("SPEED: 1", 1);
        this.printMessage("STATUS: ", 2);
        //this.drawKey(partSize * 12, partSize * 3 + partSize * 3 / 4, Color.rgb(179, 0, 0), 1);
//        this.drawTreasure(partSize * 13, partSize * 3 + partSize * 3 / 4, 1);
        this.drawBottle(partSize * 14, partSize * 3 + partSize * 3 / 4, 1, 0);
        this.drawBottle(partSize * 15, partSize * 3 + partSize * 3 / 4, 1, 0);

        paint.setColor(Color.rgb(230, 230, 255));

// восстанавливаем холст
        invalidate();
    }

    public void mazePrint(Cell[][] maze)
    {
        float partSize = (float)dispHeight / 11;

        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeJoin(Paint.Join.ROUND);
        paint.setStrokeCap(Paint.Cap.ROUND);
        paint.setColor(Color.rgb(0, 72, 145));
        //canvas.drawRect(partSize, partSize, partSize*10, partSize*10, paint);
        float coordX, coordY;
        for(int i = 0; i < size; i++)
        {
            coordX = partSize*koeffO + partSize*i;
            for(int j = 0; j < size; j++)
            {
                coordY = partSize*koeffO + partSize*j;

                if(maze[i][j].getWall(1))
                    mCanvas.drawLine(coordX*koeffD, coordY*koeffD, (coordX+ partSize)*koeffD, coordY*koeffD, paint);
                if(maze[i][j].getWall(2))
                    mCanvas.drawLine(coordX*koeffD, (coordY + partSize)*koeffD, (coordX + partSize)*koeffD, (coordY + partSize)*koeffD, paint);
                if(maze[i][j].getWall(3))
                    mCanvas.drawLine(coordX*koeffD, coordY*koeffD, coordX*koeffD, (coordY + partSize)*koeffD, paint);
                if(maze[i][j].getWall(4))
                    mCanvas.drawLine((coordX + partSize)*koeffD, coordY*koeffD, (coordX + partSize)*koeffD, (coordY + partSize)*koeffD, paint);

                if(maze[i][j].getContent() == "key")
                {
                    this.drawKey(i, j, colorKeyDoor(i, j, maze, 1),0);
                }

                if(maze[i][j].getContent() == "treasure")
                {
                    this.drawTreasure(i, j, 0);
                }

                if(maze[i][j].getContent() == "stick")
                {
                    this.drawBottle(i, j, 0, 1);
                }

                if(maze[i][j].getContent() == "dart")
                {
                    this.drawTraps(i, j, 0);
                }

                if(maze[i][j].getContent() == "poisonDart")
                {
                    this.drawTraps(i, j, 1);
                }

                if(maze[i][j].getContent() == "trap")
                {
                    this.drawTraps(i, j, 2);
                }
                paint.setColor(Color.rgb(0, 72, 145));
            }
        }

        for(int i = 0; i < size; i++)
        {
            drawWall(0, i, 3, maze);
            drawWall(size-1, i, 4, maze);
            drawWall(i, 0, 1, maze);
            drawWall(i, size-1, 2, maze);
        }

      paint.setColor(Color.rgb(230, 230, 255));
// восстанавливаем холст
        invalidate();
    }

    public void drawHero(int X, int Y, int col)
    {
        float coordX, coordY;
        float partSize = (float)dispHeight / 11;
        coordX = partSize*koeffO + partSize*X;
        coordY = partSize*koeffO + partSize*Y;

        paint.setStrokeWidth(1);
        paint.setStyle(Paint.Style.FILL);
        paint.setColor(col);
        mCanvas.drawCircle(coordX * koeffD + partSize * koeffD / 2, coordY * koeffD + partSize * koeffD / 2, partSize * koeffD / 3, paint);
        paint.setColor(Color.rgb(230, 230, 255));
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(4);
        invalidate();
    }

    public void drawCell(float X, float Y, int type)
    {
        float coordX, coordY;
        float partSize = (float)dispHeight / 11;
        coordX = partSize*koeffO + partSize*X;
        coordY = partSize*koeffO + partSize*Y;

        paint.setColor(Color.rgb(230, 230, 255));
        paint.setStyle(Paint.Style.FILL_AND_STROKE);
        paint.setStrokeWidth(1);

        switch (type)
        {
            case 0://cell
            {
                mCanvas.drawRect(coordX * koeffD + partSize * koeffD/10, coordY * koeffD + partSize * koeffD/10, coordX * koeffD + partSize*9 * koeffD/10, coordY * koeffD + partSize*9 * koeffD/10, paint);
                break;
            }
            case 1://inv
            {
                coordX = X;
                coordY = Y;
                mCanvas.drawRect(coordX + partSize/10, coordY + partSize/10, coordX + partSize*9/10, coordY + partSize*9/10, paint);
                break;
            }
        }

        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(4);
        invalidate();
    }

    public void drawKey(float X, float Y, int col, int type)
    {
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(2);

        float radius,coordX, coordY;
        float partSize = (float)dispHeight / 11;
        radius = partSize*2/16;
        coordX = partSize*koeffO + partSize*X;
        coordY = partSize*koeffO + partSize*Y;

        paint.setColor(col);

        switch (type)
        {
            case 0://cell
            {
                mCanvas.drawCircle(coordX*koeffD + partSize*koeffD/2, coordY*koeffD + partSize*koeffD/3, radius*koeffD, paint);
                mCanvas.drawLine(coordX*koeffD + partSize*koeffD/2, coordY*koeffD + partSize*koeffD/3 + radius*koeffD, coordX*koeffD + partSize*koeffD/2, coordY*koeffD + partSize*koeffD/3 + radius*koeffD + 2*radius*koeffD, paint);
                mCanvas.drawLine(coordX*koeffD + partSize*koeffD/2, coordY*koeffD + partSize*koeffD/3 + 2*radius*koeffD, coordX*koeffD + partSize*koeffD/2 + radius*koeffD, coordY*koeffD + partSize*koeffD/3 + 2*radius*koeffD, paint);
                mCanvas.drawLine(coordX*koeffD + partSize*koeffD/2, coordY*koeffD + partSize*koeffD/3 + 2*radius*koeffD + radius*koeffD/2, coordX*koeffD + partSize*koeffD/2 + radius*koeffD/2, coordY*koeffD + partSize*koeffD/3 + 2*radius*koeffD + radius*koeffD/2, paint);
                mCanvas.drawLine(coordX*koeffD + partSize*koeffD/2, coordY*koeffD + partSize*koeffD/3 + radius*koeffD + 2*radius*koeffD, coordX*koeffD + partSize*koeffD/2 + radius*koeffD, coordY*koeffD + partSize*koeffD/3 + radius*koeffD + 2*radius*koeffD, paint);
                break;
            }
            case 1://inventory
            {
                coordX = X;
                coordY = Y;
                mCanvas.drawCircle(coordX + partSize/2, coordY + partSize/3, radius, paint);
                mCanvas.drawLine(coordX + partSize/2, coordY + partSize/3 + radius, coordX + partSize/2, coordY + partSize/3 + radius + 2*radius, paint);
                mCanvas.drawLine(coordX + partSize/2, coordY + partSize/3 + 2*radius, coordX + partSize/2 + radius, coordY + partSize/3 + 2*radius, paint);
                mCanvas.drawLine(coordX + partSize/2, coordY + partSize/3 + 2*radius + radius/2, coordX + partSize/2 + radius/2, coordY + partSize/3 + 2*radius + radius/2, paint);
                mCanvas.drawLine(coordX + partSize/2, coordY + partSize/3 + radius + 2*radius, coordX + partSize/2 + radius, coordY + partSize/3 + radius + 2*radius, paint);
                break;
            }
        }


        paint.setStrokeWidth(4);
        paint.setColor(Color.rgb(230, 230, 255));
        invalidate();
    }

    public void drawTreasure(float X, float Y, int type)
    {
        paint.setStyle(Paint.Style.FILL);
        paint.setStrokeWidth(2);

        float coordX, coordY;
        float partSize = (float)dispHeight / 11;
        coordX = partSize*koeffO + partSize*X;
        coordY = partSize*koeffO + partSize*Y;

        switch (type)
        {
            case 0://cell
            {
                paint.setColor(Color.rgb(136, 0, 21));
                mCanvas.drawRect(coordX*koeffD + partSize*koeffD/10, coordY*koeffD + partSize*koeffD/10, coordX*koeffD + partSize*9*koeffD/10, coordY*koeffD + partSize*9*koeffD/10, paint);
                paint.setColor(Color.rgb(255, 201, 14));
                paint.setStyle(Paint.Style.STROKE);
                paint.setStrokeWidth(1);
                mCanvas.drawRect(coordX*koeffD + partSize*koeffD/10, coordY*koeffD + partSize*koeffD/10, coordX*koeffD + partSize*9*koeffD/10, coordY*koeffD + partSize*9*koeffD/10, paint);
                paint.setStyle(Paint.Style.FILL);
                paint.setStrokeWidth(2);
                mCanvas.drawLine(coordX*koeffD + partSize*koeffD/10, coordY*koeffD + partSize*koeffD/10 + (partSize*8*koeffD/10)/3, coordX*koeffD + partSize*9*koeffD/10, coordY*koeffD + partSize*koeffD/10 + (partSize*8*koeffD/10)/3, paint);
                mCanvas.drawRect(coordX*koeffD + partSize*koeffD/10 + (partSize*8*koeffD/10)/3, coordY*koeffD + partSize*koeffD/10 + (partSize*8*koeffD/10)*1/4, coordX*koeffD + partSize*koeffD/10 + (partSize*8*koeffD/10)*2/3, coordY*koeffD + partSize*koeffD/10 + (partSize*8*koeffD/10)*1/4 + ((partSize*8*koeffD/10)/3)/2, paint);
                break;
            }
            case 1://inventory
            {
                coordX = X;
                coordY = Y;
                paint.setColor(Color.rgb(136, 0, 21));
                mCanvas.drawRect(coordX + partSize/10, coordY + partSize/10, coordX + partSize*9/10, coordY + partSize*9/10, paint);
                paint.setColor(Color.rgb(255, 201, 14));
                paint.setStyle(Paint.Style.STROKE);
                paint.setStrokeWidth(1);
                mCanvas.drawRect(coordX + partSize/10, coordY + partSize/10, coordX + partSize*9/10, coordY + partSize*9/10, paint);
                paint.setStyle(Paint.Style.FILL);
                paint.setStrokeWidth(2);
                mCanvas.drawLine(coordX + partSize/10, coordY + partSize/10 + (partSize*8/10)/3, coordX + partSize*9/10, coordY + partSize/10 + (partSize*8/10)/3, paint);
                mCanvas.drawRect(coordX + partSize/10 + (partSize*8/10)/3, coordY + partSize/10 + (partSize*8/10)*1/4, coordX + partSize/10 + (partSize*8/10)*2/3, coordY + partSize/10 + (partSize*8/10)*1/4 + ((partSize*8/10)/3)/2, paint);
                break;
            }
        }

        paint.setStrokeWidth(4);
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(Color.rgb(230, 230, 255));
        invalidate();
    }

    public void drawWall(int X, int Y, int way, Cell[][] maze)
    {
        float coordX, coordY;
        float partSize = (float)dispHeight / 11;
        coordX = partSize*koeffO + partSize*X;
        coordY = partSize*koeffO + partSize*Y;

        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeJoin(Paint.Join.ROUND);
        paint.setStrokeCap(Paint.Cap.ROUND);

        paint.setColor(Color.rgb(0, 72, 145));
        switch(way)
        {
            case 1://left
            {
                if(maze[X][Y].getDoorPos() == "left")
                    paint.setColor(colorKeyDoor(X, Y, maze, 0));
                if(maze[X][Y].getWall(1))
                    mCanvas.drawLine(coordX*koeffD, coordY*koeffD, (coordX+ partSize)*koeffD, coordY*koeffD, paint);
                break;
            }
            case 2://right
            {
                if(maze[X][Y].getDoorPos() == "right")
                    paint.setColor(colorKeyDoor(X, Y, maze, 0));
                if(maze[X][Y].getWall(2))
                    mCanvas.drawLine(coordX*koeffD, (coordY + partSize)*koeffD, (coordX + partSize)*koeffD, (coordY + partSize)*koeffD, paint);
                break;
            }
            case 3://up
            {
                if(maze[X][Y].getDoorPos() == "up")
                    paint.setColor(colorKeyDoor(X, Y, maze, 0));
                if(maze[X][Y].getWall(3))
                    mCanvas.drawLine(coordX*koeffD, coordY*koeffD, coordX*koeffD, (coordY + partSize)*koeffD, paint);
                break;
            }
            case 4://down
            {
                if(maze[X][Y].getDoorPos() == "down")
                    paint.setColor(colorKeyDoor(X, Y, maze, 0));
                if(maze[X][Y].getWall(4))
                    mCanvas.drawLine((coordX + partSize)*koeffD, coordY*koeffD, (coordX + partSize)*koeffD, (coordY + partSize)*koeffD, paint);
                break;
            }
        }

        paint.setColor(Color.rgb(230, 230, 255));
        invalidate();
    }

    public int colorKeyDoor(int X, int Y, Cell[][] maze, int type)
    {
        String tmp = "";
        switch (type)
        {
            case 0://door
            {
                tmp = maze[X][Y].getDoorType();
                break;
            }
            case 1://key
            {
                tmp = maze[X][Y].getKeyType();
                break;
            }
        }
        if(tmp == "wood")
        {
            return Color.rgb(116, 58, 58);
            //paint.setColor(Color.rgb(116, 58, 58));
        }
        if(tmp == "metal")
        {
            return Color.rgb(75, 150, 150);
            //paint.setColor(Color.rgb(75, 150, 150));
        }
        if(tmp == "stone")
        {
            return Color.rgb(128, 128, 128);
            //paint.setColor(Color.rgb(128, 128, 128));
        }
        if(tmp == "gold")
        {
            return Color.rgb(255, 201, 14);
            //paint.setColor(Color.rgb(255, 201, 14));
        }
        if(tmp == "none")
        {
            return Color.rgb(0, 72, 145);
            //paint.setColor(Color.rgb(0, 72, 145));
        }
        return Color.rgb(0, 72, 145);
    }

    public void drawBottle(float X, float Y, int type, int col)
    {
        //type 0 - cell, 1 - inventory
        //col 0 - heal, 1 - speed
        float coordX, coordY;
        float partSize = (float)dispHeight / 11;
        coordX = partSize*koeffO + partSize*X;
        coordY = partSize*koeffO + partSize*Y;

        paint.setStrokeJoin(Paint.Join.ROUND);
        paint.setStrokeCap(Paint.Cap.ROUND);
        paint.setStrokeWidth(1);

        switch (col)
        {
            case 0://heal
            {
                paint.setColor(Color.RED);
                break;
            }
            case 1://speed
            {
                paint.setColor(Color.BLUE);
                break;
            }
        }

        Path bottleCell = new Path();
        bottleCell.moveTo(coordX*koeffD + partSize*koeffD/10, coordY*koeffD + partSize*9*koeffD/10);
        bottleCell.lineTo(coordX*koeffD + partSize*koeffD/10 + (partSize*8*koeffD/10)/3, coordY*koeffD + partSize*9*koeffD/10 - (partSize*8*koeffD/10)*2/3);
        bottleCell.lineTo(coordX*koeffD + partSize*koeffD/10 + (partSize*8*koeffD/10)/3, coordY*koeffD + partSize*koeffD/10);
        bottleCell.lineTo(coordX*koeffD + partSize*koeffD/10 + (partSize*8*koeffD/10)*2/3, coordY*koeffD + partSize*koeffD/10);
        bottleCell.lineTo(coordX*koeffD + partSize*koeffD/10 + (partSize*8*koeffD/10)*2/3, coordY*koeffD + partSize*koeffD*9/10 - (partSize*8*koeffD/10)*2/3);
        bottleCell.lineTo(coordX*koeffD + partSize*koeffD*9/10, coordY*koeffD + partSize*koeffD*9/10);
        bottleCell.lineTo(coordX*koeffD + partSize*koeffD/10, coordY*koeffD + partSize*9*koeffD/10);

        Path bottleInv = new Path();
        coordX = X;
        coordY = Y;
        bottleInv.moveTo(coordX + partSize/10, coordY + partSize*9/10);
        bottleInv.lineTo(coordX + partSize/10 + (partSize*8/10)/3, coordY + partSize*9/10 - (partSize*8/10)*2/3);
        bottleInv.lineTo(coordX + partSize/10 + (partSize*8/10)/3, coordY + partSize/10);
        bottleInv.lineTo(coordX + partSize/10 + (partSize*8/10)*2/3, coordY + partSize/10);
        bottleInv.lineTo(coordX + partSize/10 + (partSize*8/10)*2/3, coordY + partSize*9/10 - (partSize*8/10)*2/3);
        bottleInv.lineTo(coordX + partSize*9/10, coordY + partSize*9/10);
        bottleInv.lineTo(coordX + partSize/10, coordY + partSize*9/10);


        switch (type)
        {
            case 0://cell
            {
                paint.setStyle(Paint.Style.FILL);
                mCanvas.drawPath(bottleCell, paint);

                paint.setStyle(Paint.Style.STROKE);
                paint.setColor(Color.rgb(255, 201, 14));
                mCanvas.drawPath(bottleCell, paint);

                break;
            }
            case 1://inventory
            {
                paint.setStyle(Paint.Style.FILL);
                mCanvas.drawPath(bottleInv, paint);

                paint.setStyle(Paint.Style.STROKE);
                paint.setColor(Color.rgb(255, 201, 14));
                mCanvas.drawPath(bottleInv, paint);
                break;
            }
        }


        paint.setStrokeWidth(4);
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(Color.rgb(230, 230, 255));
        invalidate();
    }

    public void drawTraps(float X, float Y, int type)
    {
        //type 0 - dart 1 - poison dart 2 - trap
        float coordX, coordY;
        float partSize = (float)dispHeight / 11;
        coordX = partSize*koeffO + partSize*X;
        coordY = partSize*koeffO + partSize*Y;

        paint.setStrokeWidth(1);

        paint.setColor(Color.rgb(202, 202, 255));
        paint.setStyle(Paint.Style.FILL);
        mCanvas.drawRect(coordX*koeffD + partSize*koeffD/10, coordY*koeffD + partSize*koeffD/10, coordX*koeffD + partSize*9*koeffD/10, coordY*koeffD + partSize*9*koeffD/10, paint);

        switch(type)
        {
            case 0://dart
            {
                paint.setColor(Color.rgb(145, 0, 0));
                break;
            }

            case 1://poison dart
            {
                paint.setColor(Color.rgb(34, 177, 76));
                break;
            }

            case 2://trap
            {
                paint.setColor(Color.BLACK);
                break;
            }
        }

        if(type == 2)
        {
            paint.setStrokeWidth(2);
            paint.setStyle(Paint.Style.FILL);

            mCanvas.drawRect(coordX*koeffD + partSize*koeffD/4, coordY*koeffD + partSize*koeffD/4, coordX*koeffD + partSize*3*koeffD/4, coordY*koeffD + partSize*3*koeffD/4, paint);
            mCanvas.drawLine(coordX*koeffD + partSize*koeffD/10, coordY*koeffD + partSize*koeffD/10, coordX*koeffD + partSize*9*koeffD/10, coordY*koeffD + partSize*9*koeffD/10, paint);
            mCanvas.drawLine(coordX*koeffD + partSize*koeffD/10, coordY*koeffD + partSize*9*koeffD/10, coordX*koeffD + partSize*9*koeffD/10, coordY*koeffD + partSize*koeffD/10, paint);
        }
        else
        {
            paint.setStrokeWidth(1);
            paint.setStyle(Paint.Style.FILL);
            float radius = (partSize*8/10)/8;
            mCanvas.drawCircle (coordX*koeffD + partSize*koeffD/2, coordY*koeffD + partSize*koeffD/2 + radius*5*koeffD/2, radius*koeffD, paint);
            mCanvas.drawCircle (coordX*koeffD + partSize*koeffD/2, coordY*koeffD + partSize*koeffD/2, radius*koeffD, paint);
            mCanvas.drawCircle (coordX*koeffD + partSize*koeffD/2, coordY*koeffD + partSize*koeffD/2 - radius*5*koeffD/2, radius*koeffD, paint);
            mCanvas.drawCircle (coordX*koeffD + partSize*koeffD/2 - radius*75*koeffD/32, coordY*koeffD + partSize*koeffD/2 + radius*5*koeffD/4, radius*koeffD, paint);
            mCanvas.drawCircle (coordX*koeffD + partSize*koeffD/2 - radius*75*koeffD/32, coordY*koeffD + partSize*koeffD/2 - radius*5*koeffD/4, radius*koeffD, paint);
            mCanvas.drawCircle (coordX*koeffD + partSize*koeffD/2 + radius*75*koeffD/32, coordY*koeffD + partSize*koeffD/2 + radius*5*koeffD/4, radius*koeffD, paint);
            mCanvas.drawCircle (coordX*koeffD + partSize*koeffD/2 + radius*75*koeffD/32, coordY*koeffD + partSize*koeffD/2 - radius*5*koeffD/4, radius*koeffD, paint);
        }

        paint.setStrokeWidth(4);
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(Color.rgb(230, 230, 255));
        invalidate();
    }

    public void printMessage(String mes, int type)
    {
        float partSize = (float)dispHeight / 11;
        paint.setStyle(Paint.Style.FILL);
        paint.setTextSize(partSize*2/4);

        switch (type)
        {
            case 0://health
            {
                paint.setColor(Color.rgb(230, 230, 255));
                mCanvas.drawRect(partSize*12, partSize*3-partSize*3/4, partSize*30, partSize*2-partSize*3/4, paint);
                paint.setColor(Color.rgb(179, 0, 0));
                mCanvas.drawText(mes, partSize*12, partSize*3-partSize*3/4, paint);
                break;
            }
            case 1://speed
            {
                paint.setColor(Color.rgb(230, 230, 255));
                mCanvas.drawRect(partSize*12, partSize*3, partSize*30, partSize*3-partSize*3/4, paint);
                paint.setColor(Color.rgb(0, 0, 150));
                mCanvas.drawText(mes, partSize*12, partSize*3, paint);
                break;
            }
            case 2://status
            {
                paint.setColor(Color.rgb(230, 230, 255));
                mCanvas.drawRect(partSize*12, partSize*3+partSize*3/4, partSize*30, partSize*3, paint);
                paint.setColor(Color.rgb(0, 100, 0));
                mCanvas.drawText(mes, partSize*12, partSize*3+partSize*3/4, paint);
                break;
            }
        }
        paint.setStrokeWidth(4);
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(Color.rgb(230, 230, 255));
        invalidate();
    }
    public void viewToast(String message)
    {
        Toast toast = Toast.makeText(my,
                message,
                Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.BOTTOM, 0, 0);
        toast.show();
    }
}
